package com.jumptap.adtag.activity;

import android.app.Activity;
import android.content.res.Configuration;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.os.Bundle;
import android.view.Display;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.VideoView;
import com.jumptap.adtag.JtAdWidgetSettings;
import com.jumptap.adtag.JtAdWidgetSettingsFactory;
import com.jumptap.adtag.actions.ActionFactory;
import com.jumptap.adtag.actions.AdAction;
import com.jumptap.adtag.listeners.JtAdViewInnerListener;
import com.jumptap.adtag.media.JTMediaPlayer;

public class JTVideoActivity extends Activity
  implements JtAdViewInnerListener, MediaPlayer.OnCompletionListener
{
  private static final int LEARN_MORE_BTN_ID = 77777777;
  private static final int SKIP_BTN_ID = 8888888;
  private Button learnMoreBtn;
  private RelativeLayout.LayoutParams learnMoreBtnRlp;
  private Button skipBtn;
  private RelativeLayout.LayoutParams skipBtnRlp;
  private VideoView videoView;

  private void closeActivity()
  {
    runOnUiThread(new Runnable()
    {
      public void run()
      {
        JTMediaPlayer.getInstance().release();
        JTVideo.prepare(JtAdWidgetSettingsFactory.createWidgetSettings(), JTVideoActivity.this, true);
        JTVideoActivity.this.finish();
      }
    });
  }

  private void configLearnMoreBtnOnClickListener()
  {
    final String str = JTVideo.getClickThroughUrl();
    if ((str != null) && (!str.equals("")))
    {
      this.learnMoreBtn.setOnClickListener(new View.OnClickListener()
      {
        public void onClick(View paramAnonymousView)
        {
          new Thread(new Runnable()
          {
            public void run()
            {
              JtAdWidgetSettings localJtAdWidgetSettings = JTVideoActivity.this.getWidgetSettings();
              AdAction localAdAction = ActionFactory.createAction(JTVideoActivity.1.this.val$clickThroughUrl, localJtAdWidgetSettings.getUserAgent(null));
              localAdAction.setRedirectedUrl(JTVideoActivity.1.this.val$clickThroughUrl);
              localAdAction.perform(JTVideoActivity.this, null);
              JTVideoActivity.this.closeActivity();
            }
          }).start();
        }
      });
      return;
    }
    this.learnMoreBtn.setVisibility(8);
  }

  private void initJtMediaPlayer()
  {
    JTMediaPlayer localJTMediaPlayer = JTMediaPlayer.getInstance();
    localJTMediaPlayer.setOnCompletionListener(this);
    localJTMediaPlayer.setVideoView(this.videoView);
  }

  private void initUI()
  {
    int i = getWindowManager().getDefaultDisplay().getWidth();
    RelativeLayout localRelativeLayout = new RelativeLayout(this);
    localRelativeLayout.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
    setLearnMoreButton();
    this.learnMoreBtnRlp = new RelativeLayout.LayoutParams(i / 2, 35);
    this.learnMoreBtnRlp.addRule(6);
    localRelativeLayout.addView(this.learnMoreBtn, this.learnMoreBtnRlp);
    setSkipButton();
    this.skipBtnRlp = new RelativeLayout.LayoutParams(i / 2, 35);
    this.skipBtnRlp.addRule(6);
    this.skipBtnRlp.addRule(1, 77777777);
    localRelativeLayout.addView(this.skipBtn, this.skipBtnRlp);
    RelativeLayout.LayoutParams localLayoutParams = new RelativeLayout.LayoutParams(-2, -2);
    localLayoutParams.addRule(3, 8888888);
    this.videoView = new VideoView(this);
    localRelativeLayout.addView(this.videoView, localLayoutParams);
    setContentView(localRelativeLayout);
  }

  // ERROR //
  private void sendTrackingLink()
  {
    // Byte code:
    //   0: invokestatic 164	com/jumptap/adtag/activity/JTVideo:getTrackingUrl	()Ljava/util/List;
    //   3: astore_1
    //   4: aload_1
    //   5: ifnull +194 -> 199
    //   8: new 166	org/apache/http/impl/client/DefaultHttpClient
    //   11: dup
    //   12: invokespecial 167	org/apache/http/impl/client/DefaultHttpClient:<init>	()V
    //   15: astore_2
    //   16: aload_1
    //   17: invokeinterface 173 1 0
    //   22: astore_3
    //   23: aload_3
    //   24: invokeinterface 179 1 0
    //   29: ifeq +170 -> 199
    //   32: aload_3
    //   33: invokeinterface 183 1 0
    //   38: checkcast 63	java/lang/String
    //   41: astore 4
    //   43: aload 4
    //   45: ifnull +76 -> 121
    //   48: iconst_1
    //   49: istore 5
    //   51: aload 4
    //   53: ldc 61
    //   55: invokevirtual 67	java/lang/String:equals	(Ljava/lang/Object;)Z
    //   58: ifne +69 -> 127
    //   61: iconst_1
    //   62: istore 6
    //   64: iload 5
    //   66: iload 6
    //   68: iand
    //   69: ifeq -46 -> 23
    //   72: new 185	org/apache/http/client/methods/HttpGet
    //   75: dup
    //   76: aload 4
    //   78: invokespecial 188	org/apache/http/client/methods/HttpGet:<init>	(Ljava/lang/String;)V
    //   81: astore 7
    //   83: aload_2
    //   84: aload 7
    //   86: invokeinterface 194 2 0
    //   91: pop
    //   92: ldc 196
    //   94: new 198	java/lang/StringBuilder
    //   97: dup
    //   98: invokespecial 199	java/lang/StringBuilder:<init>	()V
    //   101: ldc 201
    //   103: invokevirtual 205	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   106: aload 4
    //   108: invokevirtual 205	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   111: invokevirtual 208	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   114: invokestatic 214	android/util/Log:i	(Ljava/lang/String;Ljava/lang/String;)I
    //   117: pop
    //   118: goto -95 -> 23
    //   121: iconst_0
    //   122: istore 5
    //   124: goto -73 -> 51
    //   127: iconst_0
    //   128: istore 6
    //   130: goto -66 -> 64
    //   133: astore 8
    //   135: ldc 196
    //   137: new 198	java/lang/StringBuilder
    //   140: dup
    //   141: invokespecial 199	java/lang/StringBuilder:<init>	()V
    //   144: ldc 216
    //   146: invokevirtual 205	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   149: aload 4
    //   151: invokevirtual 205	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   154: invokevirtual 208	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   157: aload 8
    //   159: invokestatic 220	android/util/Log:e	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
    //   162: pop
    //   163: goto -140 -> 23
    //   166: astore 10
    //   168: ldc 196
    //   170: new 198	java/lang/StringBuilder
    //   173: dup
    //   174: invokespecial 199	java/lang/StringBuilder:<init>	()V
    //   177: ldc 216
    //   179: invokevirtual 205	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   182: aload 4
    //   184: invokevirtual 205	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   187: invokevirtual 208	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   190: aload 10
    //   192: invokestatic 220	android/util/Log:e	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
    //   195: pop
    //   196: goto -173 -> 23
    //   199: return
    //   200: astore 10
    //   202: goto -34 -> 168
    //   205: astore 8
    //   207: goto -72 -> 135
    //
    // Exception table:
    //   from	to	target	type
    //   72	83	133	org/apache/http/client/ClientProtocolException
    //   72	83	166	java/io/IOException
    //   83	118	200	java/io/IOException
    //   83	118	205	org/apache/http/client/ClientProtocolException
  }

  private void setLearnMoreButton()
  {
    this.learnMoreBtn = new Button(this);
    this.learnMoreBtn.setId(77777777);
    this.learnMoreBtn.setClickable(true);
    this.learnMoreBtn.setText("Learn more");
  }

  private void setSkipButton()
  {
    this.skipBtn = new Button(this);
    this.skipBtn.setId(8888888);
    this.skipBtn.setClickable(true);
    this.skipBtn.setText("Skip");
    this.skipBtn.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        new Thread(new Runnable()
        {
          public void run()
          {
            JTVideoActivity.this.closeActivity();
          }
        }).start();
      }
    });
  }

  public String getAdRequestId()
  {
    return JTVideo.getAdRequestId();
  }

  public JtAdWidgetSettings getWidgetSettings()
  {
    return JtAdWidgetSettingsFactory.createWidgetSettings();
  }

  public void handleClicks(String paramString)
  {
  }

  public void hide()
  {
  }

  public void onAdError(int paramInt)
  {
  }

  public void onBeginAdInteraction()
  {
  }

  public void onCompletion(MediaPlayer paramMediaPlayer)
  {
    closeActivity();
  }

  public void onConfigurationChanged(Configuration paramConfiguration)
  {
    runOnUiThread(new Runnable()
    {
      public void run()
      {
        int i = JTVideoActivity.this.getWindowManager().getDefaultDisplay().getWidth();
        JTVideoActivity.this.skipBtnRlp.width = (i / 2);
        JTVideoActivity.this.skipBtn.setLayoutParams(JTVideoActivity.this.skipBtnRlp);
        JTVideoActivity.this.skipBtn.requestLayout();
        JTVideoActivity.this.learnMoreBtnRlp.width = (i / 2);
        JTVideoActivity.this.learnMoreBtn.setLayoutParams(JTVideoActivity.this.learnMoreBtnRlp);
        JTVideoActivity.this.learnMoreBtn.requestLayout();
      }
    });
    super.onConfigurationChanged(paramConfiguration);
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    initUI();
    initJtMediaPlayer();
    sendTrackingLink();
    configLearnMoreBtnOnClickListener();
  }

  public void onEndAdInteraction()
  {
  }

  public void onInterstitialDismissed()
  {
  }

  public void onNewAd()
  {
  }

  public void onNoAdFound()
  {
  }

  protected void onPause()
  {
    super.onPause();
    closeActivity();
  }

  public boolean post(Runnable paramRunnable)
  {
    return false;
  }

  public void resize(int paramInt1, int paramInt2, boolean paramBoolean)
  {
  }

  public void resizeWithCallback(boolean paramBoolean, int paramInt1, int paramInt2, String paramString1, int paramInt3, String paramString2)
  {
  }

  public void setContent(String paramString1, String paramString2)
  {
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.jumptap.adtag.activity.JTVideoActivity
 * JD-Core Version:    0.6.2
 */